import http from '@/utils/request';
import type { DeviceLocation, DeviceLocationBo, DeviceLocationVo } from './types';
import type { PageQuery } from '@/types/axios';
import type { TableDataInfo } from '@/types/axios';

// 查询设备位置列表
export function listDeviceLocation(query: Partial<DeviceLocation>) {
    return http.get('/vending/location/list', { params: query });
}

// 分页查询设备位置列表
export function getLocationPage(bo: DeviceLocationBo, pageQuery: PageQuery) {
    return http.get<TableDataInfo<DeviceLocationVo>>('/device/api/location/page', { params: { ...bo, ...pageQuery } });
}

// 获取设备位置详细信息
export function getDeviceLocation(id: number) {
    return http.get(`/vending/api/location/${id}`);
}

// 根据设备ID查询位置信息
export function selectVoByDeviceId(deviceId: number) {
    return http.get(`/vending/api/location/device/${deviceId}`);
}

// 根据ID获取设备位置详细信息
export function getLocationInfoById(id: number) {
    return http.get<DeviceLocationVo>(`/device/api/location/byId/${id}`);
}

// 新增设备位置
export function addDeviceLocation(data: DeviceLocationBo) {
    return http.post('/vending/api/location', data);
}

// 修改设备位置
export function updateDeviceLocation(data: DeviceLocationBo) {
    return http.put('/vending/api/location', data);
}

// 删除设备位置
export function delDeviceLocation(id: number) {
    return http.delete(`/vending/api/location/${id}`);
}

// 批量删除设备位置
export function deleteLocationBatch(ids: number[]) {
    return http.delete(`/vending/api/location/batch/${ids.join(',')}`);
} 